import { View, Text, StyleSheet,Button } from 'react-native';
import React from 'react';
import Animated, { useSharedValue, useAnimatedStyle, withTiming,withRepeat,Easing } from 'react-native-reanimated';

const AnimatedView = Animated.createAnimatedComponent(View);

  export const Test1127 = () => {
    const width1 = useSharedValue(50); // 旋转动画

// 定义动画样式
const animatedStyle = useAnimatedStyle(() => ({
  width: width1.value,
  height: width1.value,
}));

// 在 useEffect 中启动动画
React.useEffect(() => {
  width1.value = withRepeat(
    withTiming(300, { duration: 1000, easing: Easing.linear }),
    -1,
    true // 来回动画
  );
}, []);

return (
  <AnimatedView
    style={[
      {backgroundColor: 'gold' }, // 静态样式
      animatedStyle, // 动态样式
    ]}
  />
);
  }